package homework_;

/**
 * @author 徐州城
 * @version 1.0
 */
public class Homework02 {
    public static void main(String[] args) {
        //说出下面代码是否会发生异常，如果会，是哪种异常？如果不会，则打印结果是什么
        try {
            args[4] = null;
            if (args[4].equals("john")){ //空指针异常
                System.out.println("AA");
            }else {
                System.out.println("BB");
            }

            Object o = args[2]; //数组索引越界异常
            Integer i = (Integer) o; //类型转换异常
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("索引越界: " + e.getMessage());
        } catch (NullPointerException e){
            System.out.println("空指针异常: " + e.getMessage());
        } catch (ClassCastException e){
            System.out.println("类型转换异常: " + e.getMessage());
        }
    }
}
